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

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

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

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

f = A("f")
d = B("d")
j = C("j")
b = D("b")
i = B("i")

f.t = i
d.o = f
d.p = f
d.w = j
d.q = i
j.y = f
j.x = d
b.q = j
b.t = i
b.r = f
i.o = f
i.p = f
i.w = j
i.q = d
assert j.x.q.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

f = A("f")
d = B("d")
j = C("j")
b = D("b")
i = B("i")

f.t = i
d.o = f
d.p = f
d.w = j
d.q = i
j.y = f
j.x = d
b.q = j
b.t = i
b.r = f
i.o = f
i.p = f
i.w = j
i.q = d
assert j.x.q.o.t.txt == "i"