class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.p: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.o: C = None
        self.x: E = None
        self.u: F = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: C = None
        self.y: C = None
        self.r: B = None
        self.p: E = None
        self.txt = txt

a = A("a")
g = B("g")
j = C("j")
n = D("n")
c = E("c")
b = F("b")
l = B("l")

a.u = b
a.p = c
g.u = a
j.x = c
j.w = a
n.v = j
n.o = j
n.x = c
n.u = b
c.t = n
b.u = g
b.r = g
b.q = j
b.y = j
b.p = c
l.u = a
assert g.u.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.p: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.o: C = None
        self.x: E = None
        self.u: F = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: C = None
        self.y: C = None
        self.r: B = None
        self.p: E = None
        self.txt = txt

a = A("a")
g = B("g")
j = C("j")
n = D("n")
c = E("c")
b = F("b")
l = B("l")

a.u = b
a.p = c
g.u = a
j.x = c
j.w = a
n.v = j
n.o = j
n.x = c
n.u = b
c.t = n
b.u = g
b.r = g
b.q = j
b.y = j
b.p = c
l.u = a
assert g.u.u.r.txt == "g"