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

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

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

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

h = A("h")
f = B("f")
k = C("k")
a = D("a")
j = C("j")

h.v = a
h.u = j
h.t = j
f.u = h
k.o = a
k.q = j
k.u = j
k.p = h
a.p = k
j.o = a
j.q = k
j.u = k
j.p = h
assert j.o.p.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.u: C = None
        self.t: C = None
        self.txt = txt

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

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

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

h = A("h")
f = B("f")
k = C("k")
a = D("a")
j = C("j")

h.v = a
h.u = j
h.t = j
f.u = h
k.o = a
k.q = j
k.u = j
k.p = h
a.p = k
j.o = a
j.q = k
j.u = k
j.p = h
assert j.o.p.o.p.txt == "k"