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

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

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

class D:
    def __init__(self, txt: str):
        self.o: A = None
        self.u: C = None
        self.w: D = None
        self.txt = txt

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

g.p = n
g.t = n
n.y = c
k.t = n
i.o = g
i.u = c
i.w = e
e.o = g
e.u = k
e.w = i
c.t = n
assert k.t.y.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.t: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: A = None
        self.u: C = None
        self.w: D = None
        self.txt = txt

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

g.p = n
g.t = n
n.y = c
k.t = n
i.o = g
i.u = c
i.w = e
e.o = g
e.u = k
e.w = i
c.t = n
assert k.t.y.t.y.txt == "c"