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

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

class C:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: B = None
        self.v: D = None
        self.q: A = None
        self.txt = txt

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

f = A("f")
a = B("a")
b = C("b")
d = D("d")
k = B("k")
h = A("h")

f.o = b
a.y = d
b.z = a
b.r = k
b.v = d
b.q = f
d.t = b
d.o = b
d.s = f
d.v = k
k.y = d
h.o = b
assert f.o.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: B = None
        self.v: D = None
        self.q: A = None
        self.txt = txt

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

f = A("f")
a = B("a")
b = C("b")
d = D("d")
k = B("k")
h = A("h")

f.o = b
a.y = d
b.z = a
b.r = k
b.v = d
b.q = f
d.t = b
d.o = b
d.s = f
d.v = k
k.y = d
h.o = b
assert f.o.r.y.txt == "d"