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

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: B = None
        self.y: A = None
        self.t: F = None
        self.p: A = None
        self.v: C = None
        self.txt = txt

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

b = A("b")
m = B("m")
g = C("g")
e = D("e")
k = E("k")
j = F("j")

b.q = e
b.t = k
m.r = g
g.q = m
g.o = e
e.o = j
e.s = j
k.s = m
k.y = b
k.p = b
k.t = j
k.v = g
j.t = g
j.u = g
j.r = b
assert j.t.q.r.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.t: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: B = None
        self.y: A = None
        self.t: F = None
        self.p: A = None
        self.v: C = None
        self.txt = txt

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

b = A("b")
m = B("m")
g = C("g")
e = D("e")
k = E("k")
j = F("j")

b.q = e
b.t = k
m.r = g
g.q = m
g.o = e
e.o = j
e.s = j
k.s = m
k.y = b
k.p = b
k.t = j
k.v = g
j.t = g
j.u = g
j.r = b
assert j.t.q.r.o.o.txt == "j"