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

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

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

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

k = A("k")
l = B("l")
c = C("c")
m = D("m")
g = B("g")

k.z = g
k.t = c
l.p = g
l.v = g
l.q = m
l.s = c
c.q = k
m.s = c
m.r = k
g.p = l
g.v = l
g.q = m
g.s = c
assert g.q.s.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.t: C = None
        self.txt = txt

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

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

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

k = A("k")
l = B("l")
c = C("c")
m = D("m")
g = B("g")

k.z = g
k.t = c
l.p = g
l.v = g
l.q = m
l.s = c
c.q = k
m.s = c
m.r = k
g.p = l
g.v = l
g.q = m
g.s = c
assert g.q.s.q.z.txt == "g"