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

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

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

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

f = A("f")
h = B("h")
g = C("g")
l = D("l")
b = A("b")
n = A("n")
c = B("c")

f.v = c
h.q = c
h.o = c
g.z = l
g.y = l
l.q = g
l.s = g
l.t = f
l.w = h
b.v = c
n.v = c
c.q = h
c.o = h
assert n.v.o.o.q.q.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

f = A("f")
h = B("h")
g = C("g")
l = D("l")
b = A("b")
n = A("n")
c = B("c")

f.v = c
h.q = c
h.o = c
g.z = l
g.y = l
l.q = g
l.s = g
l.t = f
l.w = h
b.v = c
n.v = c
c.q = h
c.o = h
assert n.v.o.o.q.q.q.o.txt == "c"