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

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: C = None
        self.o: B = None
        self.t: B = None
        self.txt = txt

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

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

a = A("a")
i = B("i")
c = C("c")
d = D("d")
f = A("f")
k = B("k")
j = D("j")
g = C("g")

a.q = i
a.r = i
a.p = f
i.y = g
i.p = c
i.o = k
i.t = k
c.q = k
c.y = i
c.t = g
d.v = j
f.q = i
f.p = a
f.r = k
k.y = g
k.p = g
k.o = i
k.t = i
j.v = d
g.q = i
g.y = i
g.t = c
assert k.p.y.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: A = None
        self.r: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: C = None
        self.o: B = None
        self.t: B = None
        self.txt = txt

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

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

a = A("a")
i = B("i")
c = C("c")
d = D("d")
f = A("f")
k = B("k")
j = D("j")
g = C("g")

a.q = i
a.r = i
a.p = f
i.y = g
i.p = c
i.o = k
i.t = k
c.q = k
c.y = i
c.t = g
d.v = j
f.q = i
f.p = a
f.r = k
k.y = g
k.p = g
k.o = i
k.t = i
j.v = d
g.q = i
g.y = i
g.t = c
assert k.p.y.y.t.txt == "c"