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

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

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

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

k = A("k")
j = B("j")
e = C("e")
c = D("c")
h = A("h")

k.u = h
k.o = h
k.t = e
j.q = c
e.p = c
c.p = h
c.s = j
h.u = k
h.o = k
h.t = e
assert e.p.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: A = None
        self.t: C = None
        self.txt = txt

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

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

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

k = A("k")
j = B("j")
e = C("e")
c = D("c")
h = A("h")

k.u = h
k.o = h
k.t = e
j.q = c
e.p = c
c.p = h
c.s = j
h.u = k
h.o = k
h.t = e
assert e.p.p.o.txt == "k"