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

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

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

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

a = A("a")
k = B("k")
h = C("h")
j = D("j")
n = A("n")
b = B("b")
c = A("c")

a.q = b
a.r = n
a.v = n
k.s = h
h.u = b
j.w = n
j.s = n
j.o = h
n.q = k
n.r = c
n.v = c
b.s = h
c.q = k
c.r = a
c.v = a
assert a.q.s.u.s.u.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: A = None
        self.v: A = None
        self.txt = txt

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

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

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

a = A("a")
k = B("k")
h = C("h")
j = D("j")
n = A("n")
b = B("b")
c = A("c")

a.q = b
a.r = n
a.v = n
k.s = h
h.u = b
j.w = n
j.s = n
j.o = h
n.q = k
n.r = c
n.v = c
b.s = h
c.q = k
c.r = a
c.v = a
assert a.q.s.u.s.u.s.u.txt == "b"