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

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

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

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

h = A("h")
a = B("a")
c = C("c")
k = D("k")
j = D("j")

h.t = c
a.t = c
a.z = h
a.x = k
c.z = h
c.s = h
k.s = j
k.q = j
k.t = h
j.s = k
j.q = k
j.t = h
assert a.x.q.s.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

h = A("h")
a = B("a")
c = C("c")
k = D("k")
j = D("j")

h.t = c
a.t = c
a.z = h
a.x = k
c.z = h
c.s = h
k.s = j
k.q = j
k.t = h
j.s = k
j.q = k
j.t = h
assert a.x.q.s.t.t.txt == "c"