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

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

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

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

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

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

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

f.r = a
h.u = j
h.w = j
h.y = b
h.x = c
b.t = i
b.q = m
j.o = f
j.z = a
m.r = h
n.q = a
n.u = h
n.s = b
c.u = j
c.w = j
c.y = b
c.x = h
i.r = c
a.r = f
assert h.x.y.q.r.u.o.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

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

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

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

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

f.r = a
h.u = j
h.w = j
h.y = b
h.x = c
b.t = i
b.q = m
j.o = f
j.z = a
m.r = h
n.q = a
n.u = h
n.s = b
c.u = j
c.w = j
c.y = b
c.x = h
i.r = c
a.r = f
assert h.x.y.q.r.u.o.r.r.txt == "f"