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

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

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

class D:
    def __init__(self, txt: str):
        self.x: D = None
        self.s: C = None
        self.v: C = None
        self.o: C = None
        self.txt = txt

g = A("g")
d = B("d")
i = C("i")
c = D("c")
m = C("m")
n = D("n")
k = A("k")

g.t = i
d.v = i
d.y = c
i.p = k
c.x = n
c.s = m
c.v = m
c.o = m
m.p = g
n.x = c
n.s = i
n.o = i
n.v = m
k.t = m
assert g.t.p.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: D = None
        self.s: C = None
        self.v: C = None
        self.o: C = None
        self.txt = txt

g = A("g")
d = B("d")
i = C("i")
c = D("c")
m = C("m")
n = D("n")
k = A("k")

g.t = i
d.v = i
d.y = c
i.p = k
c.x = n
c.s = m
c.v = m
c.o = m
m.p = g
n.x = c
n.s = i
n.o = i
n.v = m
k.t = m
assert g.t.p.t.p.txt == "g"