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

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

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

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

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

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

g = A("g")
k = B("k")
b = C("b")
i = D("i")
a = E("a")
d = F("d")
f = E("f")
l = F("l")

g.q = a
k.v = g
k.r = i
b.o = g
b.x = l
i.v = b
a.r = b
a.o = g
d.o = k
d.q = i
d.u = b
d.p = b
f.r = b
f.o = g
l.o = k
l.q = i
l.u = b
l.p = b
assert d.p.o.q.r.o.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

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

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

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

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

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

g = A("g")
k = B("k")
b = C("b")
i = D("i")
a = E("a")
d = F("d")
f = E("f")
l = F("l")

g.q = a
k.v = g
k.r = i
b.o = g
b.x = l
i.v = b
a.r = b
a.o = g
d.o = k
d.q = i
d.u = b
d.p = b
f.r = b
f.o = g
l.o = k
l.q = i
l.u = b
l.p = b
assert d.p.o.q.r.o.q.r.txt == "b"