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

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: F = None
        self.txt = txt

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

a = A("a")
c = B("c")
j = C("j")
k = D("k")
b = E("b")
h = F("h")
f = C("f")

a.u = f
a.q = h
a.v = b
c.r = f
c.u = b
c.t = b
c.o = a
j.x = c
k.r = a
b.r = h
h.u = a
h.p = c
f.x = c
assert h.p.o.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: F = None
        self.v: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: F = None
        self.txt = txt

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

a = A("a")
c = B("c")
j = C("j")
k = D("k")
b = E("b")
h = F("h")
f = C("f")

a.u = f
a.q = h
a.v = b
c.r = f
c.u = b
c.t = b
c.o = a
j.x = c
k.r = a
b.r = h
h.u = a
h.p = c
f.x = c
assert h.p.o.u.x.txt == "c"