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

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

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

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

f = A("f")
d = B("d")
g = C("g")
j = D("j")
h = A("h")
k = C("k")
i = B("i")
e = B("e")
l = D("l")

f.q = i
d.x = l
d.p = l
d.o = h
g.v = k
g.q = k
g.p = f
j.q = d
h.q = i
k.v = g
k.q = g
k.p = h
i.x = j
i.p = j
i.o = f
e.x = l
e.p = l
e.o = f
l.q = i
assert e.x.q.o.q.o.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

f = A("f")
d = B("d")
g = C("g")
j = D("j")
h = A("h")
k = C("k")
i = B("i")
e = B("e")
l = D("l")

f.q = i
d.x = l
d.p = l
d.o = h
g.v = k
g.q = k
g.p = f
j.q = d
h.q = i
k.v = g
k.q = g
k.p = h
i.x = j
i.p = j
i.o = f
e.x = l
e.p = l
e.o = f
l.q = i
assert e.x.q.o.q.o.q.o.txt == "f"