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

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

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.s: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.y: C = None
        self.t: D = None
        self.q: C = None
        self.txt = txt

j = A("j")
n = B("n")
b = C("b")
a = D("a")
k = E("k")

j.y = a
j.z = a
n.q = j
n.t = k
b.t = j
a.t = k
a.s = j
k.x = j
k.y = b
k.q = b
k.t = a
assert b.t.z.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.z: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.s: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.y: C = None
        self.t: D = None
        self.q: C = None
        self.txt = txt

j = A("j")
n = B("n")
b = C("b")
a = D("a")
k = E("k")

j.y = a
j.z = a
n.q = j
n.t = k
b.t = j
a.t = k
a.s = j
k.x = j
k.y = b
k.q = b
k.t = a
assert b.t.z.t.x.txt == "j"