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

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

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

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

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

b.q = k
b.r = f
b.y = f
i.q = j
a.y = k
k.o = f
k.q = f
k.r = a
k.p = i
j.q = i
f.o = k
f.q = k
f.r = a
f.p = j
assert a.y.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.r: D = None
        self.y: D = None
        self.txt = txt

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

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

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

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

b.q = k
b.r = f
b.y = f
i.q = j
a.y = k
k.o = f
k.q = f
k.r = a
k.p = i
j.q = i
f.o = k
f.q = k
f.r = a
f.p = j
assert a.y.r.y.txt == "k"