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

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

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

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

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

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

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

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

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

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

c.z = g
c.p = g
k.t = e
k.q = m
k.s = g
g.z = l
g.y = l
l.s = c
l.q = c
l.t = g
e.t = k
e.q = l
e.s = g
m.s = c
m.q = c
m.t = g
assert g.y.t.y.q.txt == "c"