class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: C = None
        self.y: D = None
        self.t: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.u: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

g = A("g")
h = B("h")
f = C("f")
n = D("n")
d = C("d")

g.s = f
h.o = f
h.y = n
h.t = g
f.y = n
f.u = h
n.r = f
d.y = n
d.u = h
assert d.y.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: C = None
        self.y: D = None
        self.t: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.u: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

g = A("g")
h = B("h")
f = C("f")
n = D("n")
d = C("d")

g.s = f
h.o = f
h.y = n
h.t = g
f.y = n
f.u = h
n.r = f
d.y = n
d.u = h
assert d.y.r.y.txt == "n"